local start, duration = GetSpellCooldown("Pulverize");
local gcd = start + duration;
local function GetCooldown(id)
  local start, duration = GetSpellCooldown(id);
  local cd = start + duration - gcd;
  if cd < 0 then
    return 0
  else
    return cd
  end
end

--2-) If I don't have a target or my target is not attackable / is
--dead, no need for anything else.
if (not (UnitExists("target") and UnitCanAttack("player", "target"))) or (UnitIsDeadOrGhost("target")) then
  return
end

local sundersToRemain = 3;
local _, _, _, duration = IconAura("HARMFUL", "target", "Expose Armor");
if (not duration) then
  local _, _, _, countAR1 = UnitDebuff("target", "Sunder Armor");
  local _, _, _, countAR2 = UnitDebuff("target", "Faerie Fire (Feral)");
  local _, _, _, countAR3 = UnitDebuff("target", "Faerie Fire");
  --2-) If my target does not have armor reduction to it's
  --maximum, apply faeri fire for 3 sunder stacks.
  if (not (countAR1 == sundersToRemain or countAR2 == sundersToRemain or countAR3 == sundersToRemain)) then
    return IconSpell("Faerie Fire (Feral)");
  end
end

local _, _, start, durationPulverize = IconAura("HELPFUL", "player", "Pulverize");
local pulverizeMinDuration = 6;
local _, _, _, countLac = UnitDebuff("target", "Lacerate");
if (not durationPulverize) then    
    if (not (countLac == 3)) then
        return IconSpell("Lacerate");
    else
        return IconSpell("Pulverize");
    end
elseif (start + durationPulverize - GetTime()<pulverizeMinDuration) then  
    if (not (countLac == 3)) then
        return IconSpell("Lacerate");
    else
        return IconSpell("Pulverize");
    end
end

--Alright, everything I should keep up is there. So I need
--to use stuff for instant damage now:
local mangleProcPrioDuration = 2;
local cdMangle = GetCooldown("Mangle");
if (cdMangle<=.2) then
    return IconSpell("Mangle");
end

local cdThrash = GetCooldown("Thrash");
if (cdThrash == 0) then
    return IconSpell("Thrash");
end

return IconSpell("Lacerate");
